package com.jinsi.controller;

import com.jinsi.utils.MSMUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

@Controller
public class MSMController {

    @ResponseBody
    @RequestMapping("/getMSM")
    public Map<String,String> getMSM(String phone,HttpSession session){
        Map<String, String> map = new HashMap<>();
        String templateID = "1387437";
        Integer param = MSMUtils.generateValidateCode(6);
        System.out.println(param);
        session.setAttribute("Phone",phone);
        session.setAttribute("Param",param);
        try {
//            MSM.sendShortMessage(templateID,phone,param.toString());
//            session.setAttribute("startDate",System.currentTimeMillis());
            map.put("state","200");
        } catch (Exception e) {
            e.printStackTrace();
            map.put("state","400");
        }
        return map;
    }


}
